package integration;

import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import blackjack.apple_mod;

/* CONTROL METHOD SPECIFICATION
 * INPUTs: p - CHECKED_OUTPUTs: res, area
 * 1. 	The method receives an integer (p) which identify a specific card,
 * 		verify if it is a figure, returns relative value and print the associated 
 * 		card into a TextArea.
 * 2.   Values must be in [1,13]. 
 * 3.	FIGURES: p=1->'A'; p=11->'J'; p=12->'Q'; p=13->'K';
 * 4.   The figure value is 10.
 * 5.	'A' value is only 11 (not also 1). The outer module will correct this value 
 * 		if necessary.
 * 6.	Every p in [2,10] has value equivalent to 
 * 7.	Every p not in [1,13] has value 10 for convention. 
 * 
 * TESTS SUMMARY
 * VALID TESTS
 * 	CLASS V01: p in [2,10]
 *		TEST V01_1: p = 2
 *		TEST V01_2: p = 10
 *	CLASS V02: p in [11,13] 
 *		TEST V02_1: p = 11
 *		TEST V02_2: p = 12
 *		TEST V02_3: p = 13
 *	CLASS V03: p = 1
 *		TEST V03_1: p = 1 
 * 
 * INVALID TESTS
 *	CLASS I01: p < 1
 * 		TEST I01_2: p = 0
 * 		TEST I01_3: p = -1
 * 	CLASS I02: p > 13
 * 		TEST I02_1: p = 14
 *
 */

public class controlTest {
	
	private apple_mod appleRef;
	
	// :::::::::: BEFORE METHOD ::::::::::
	@Before
	public void setUp() throws Exception {
		appleRef = new apple_mod();
	}
	
	
	// :::::::::: VALID TESTS ::::::::::
	// ***** CLASS V01: p in [2,10] *****
	// TEST V01_1: p = 2
	@Test
	public void testControl_V01_1() {
		int res;
		int val_in = 2;
		int val_out = val_in;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	// TEST V01_2: p = 10
	@Test
	public void testControl_V01_2() {
		int res;
		int val_in = 10;
		int val_out = val_in;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	
	// ***** CLASS V02: p in [11,13] *****
	// TEST V02_1: p = 11
	@Test
	public void testControl_V02_1() {
		int res;
		int val_in = 11;
		int val_out = 10;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	// TEST V02_2: p = 12
	@Test
	public void testControl_V02_2() {
		int res;
		int val_in = 12;
		int val_out = 10;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	// TEST V02_3: p = 13
	@Test
	public void testControl_V02_3() {
		int res;
		int val_in = 13;
		int val_out = 10;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	
	// ***** CLASS V03: p = 1 *****
	// TEST V03_1: p = 1
	@Test
	public void testControl_V03_1() {
		int res;
		int val_in = 1;
		int val_out = 11;
				
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	
	// :::::::::: INVALID TESTS ::::::::::
	// ***** CLASS I01: p < 1 *****
	// TEST I01_1: p = 0
	@Test
	public void testControl_I01_1() {
		int res;
		int val_in = 0;
		int val_out = 10;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	// 	TEST I01_3: p = -1
	@Test
	public void testControl_I01_2() {
		int res;
		int val_in = -1;
		int val_out = 10;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
	// ***** CLASS I02: p > 13 *****
	// TEST I01_2: p = 14
	@Test
	public void testControl_I02_1() {
		int res;
		int val_in = 14;
		int val_out = 10;
		
		res = appleRef.control(val_in);
		assertEquals(res,val_out);
	}
	
}